// 7.10 Lý do miễn giảm
import "./index.less";
import { BasicForm, useForm, FormSchema } from "@/components/Form";
import Toolbar from "@/components/ViewComponents/Toolbar";
import { useTranslation } from "react-i18next";
import { useNavigate } from "react-router-dom";
export default function emergency_reception() {
	const navigate = useNavigate();
	const { t } = useTranslation();
	let btnList = [
		"continue",
		"save"
		// "edit", "skip", "print", "end"
	];

	const formSchemaTop: FormSchema[] = [
		{
			label: t("felix_ui.pat_cardno"),
			field: "patCardno",
			component: "InputSearch",
			componentProps: {
				onSearch: (val: string) => {
					if (val) getPatientInfo(val);
				}
			},
			rules: [
				{
					required: true,
					message: t("felix_ui.please_enter_cardnum")
				}
			]
		},
		{
			label: t("felix_ui.full_name"),
			field: "fullName",
			component: "Input"
		},
		{
			label: t("felix_ui.gender"),
			field: "gender",
			component: "Select",
			componentProps: {
				options: [
					{
						label: t("felix_ui.woman"),
						value: "0"
					},
					{
						label: t("felix_ui.man"),
						value: "1"
					}
				]
			}
		},
		{
			label: t("felix_ui.age"),
			field: "age",
			component: "Input"
		},
		{
			label: t("felix_ui.address"),
			field: "address",
			component: "Input"
		},
		{
			label: t("felix_ui.ipmAdmission"),
			field: "ipmAdmission",
			component: "DatePicker",
			componentProps: {
				format: "YYYY-MM-DD"
			}
		},
		{
			label: t("felix_ui.pat_subject"),
			field: "pat_subject",
			component: "Input"
		},
		{
			label: t("felix_ui.department"),
			field: "department",
			component: "Input"
		},
		{
			label: t("felix_ui.dt_date"),
			field: "dt_date",
			component: "DatePicker"
		},
		{
			label: t("felix_ui.dt_time"),
			field: "dt_time",
			component: "DatePicker"
		},
		{
			label: t("felix_ui.numb_of_sheet"),
			field: "numb_of_sheet",
			component: "Input"
		},
		{
			label: t("felix_ui.rx_diagnosis"),
			field: "rx_diagnosis",
			component: "Input"
		},
		{
			label: t("felix_ui.prepayment"),
			field: "prepayment",
			component: "Input"
		},
		{
			label: t("felix_ui.vac_reason"),
			field: "vac_reason",
			component: "Input"
		},
		{
			label: t("felix_ui.exemption"),
			field: "exemption",
			component: "Input"
		},
		{
			label: t("felix_ui.bloodFee"),
			field: "bloodFee",
			component: "Input"
		},
		{
			label: t("felix_ui.date_from"),
			field: "date_from",
			component: "DatePicker"
		},
		{
			label: t("felix_ui.date_to"),
			field: "date_to",
			component: "DatePicker"
		},
		{
			label: t("felix_ui.departmentRepresentative"),
			field: "departmentRepresentative",
			component: "Input"
		},
		{
			label: t("task.todo.approver"),
			field: "approver",
			component: "Input"
		}
	];
	const [formTop, { validateFields }] = useForm({
		schemas: formSchemaTop,
		showActionButtonGroup: false,
		labelWidth: 120,
		baseColProps: { span: 12 }
	});
	const handleSave = async () => {};
	const handleContinue = async () => {
		return;
		let valuesTop = await validateFields();
		navigate("/MedicalExamination/4.14", {
			state: {
				patCardno: valuesTop.patCardno
			}
		});
	};
	const handlerToolbarAction = async (key: string) => {
		switch (key) {
			case "save":
				handleSave();
				break;
			case "continue":
				handleContinue();
				break;
		}
		console.log("key", key);
	};
	const getPatientInfo = async (patCardno: string) => {
		console.log(patCardno);
	};
	return (
		<div className="page flex">
			<div className="w-70% block mr-2">
				<BasicForm register={formTop} labelWrap={true}></BasicForm>
			</div>
			<div className="block" style={{ width: "calc(30% - 90px)" }}></div>
			<Toolbar action={handlerToolbarAction} btnList={btnList} />
		</div>
	);
}
